#ifndef OPEN_GL_EMBRYO_INDIVIDUAL_DISPLAY_H
#define OPEN_GL_EMBRYO_INDIVIDUAL_DISPLAY_H

#include <deque>
using std::deque;

#include "../../../graphics/GlutCallbackListener.h"

#include "EmbryoIndividualDisplay.h"

class Grid;

class OpenGlEmbryoIndividualDisplay : public EmbryoIndividualDisplay, public GlutCallbackListener {
public:
	/* ctor */
	OpenGlEmbryoIndividualDisplay(int worldWidth, int worldHeight, EmbryoIndividual& individual, int developmentalIterations);

	/* dtor */
	~OpenGlEmbryoIndividualDisplay();

	/* glut callbacks */
	void callbackIdle();
	void callbackKeyboard(unsigned char key, int x, int y);
	void callbackMouse(int button, int state, int x, int y);
	void callbackDisplay();
	void callbackReshape(int width, int height);
	void callbackSpecial(int key, int x, int y);

protected:
	/**
	 * Process events, redisplay accordingly.
	 * Should be called frequently to catch mouse, keyboard events.
	 */
	void updateDisplay();

private:
	bool _paused;
	bool _oneOff;

	/* camera */
	double _cameraX;
	double _cameraY;
	double _cameraZ;

	deque<Grid*> _gridHistory;
	int _gridIndex;
	int _lastGridIndex;

	void doSaveGrid();
};

#endif // OPEN_GL_EMBRYO_INDIVIDUAL_DISPLAY_H

